<?php
include 'functions.php';
$torrent_data = bdec(file_get_contents('[kickass.to]the.monkey.king.2014.720p.brrip.x264.ac3.jyk.torrent'));


$info = strtolower(sha1(benc($torrent_data['info'])));
$scrape = str_replace('announce', 'scrape', $torrent_data['announce']);
$sources = bdec(@file_get_contents($scrape . '?info_hash=' . urlencode(hex2bin($info))));

//print_r($torrent_data);

$c = count($torrent_data['info']['files']);
echo '<h2>Files</h2>';

if ($c > 1) {
	for ($i = 0; $i < $c; $i++) {
		echo $torrent_data['info']['files'][$i]['path']['0'] . '<br/>';
	}
} else {
	echo $torrent_data['info']['name'] . '<br/>';
}


$seeds = $sources['files'][hex2bin($info)]['complete'];
$leechs = $sources['files'][hex2bin($info)]['incomplete'];
$downloads = $sources['files'][hex2bin($info)]['downloaded'];

echo '<h2>Sources</h2>' .
	'<b>Seeds:</b> ' . $seeds . '<br/>' .
	'<b>Leechs:</b> ' . $leechs . '<br/>' .
	'<b>Downloads:</b> ' . $downloads . '<br/>';

?>